﻿
namespace _24_Hour_Blogger.Services
{
    using Microsoft.WindowsAzure.Storage;
    using Microsoft.WindowsAzure.Storage.Blob;
    using _24_Hour_Blogger.Services.Properties;

    class Program
    {
        static void Main(string[] args)
        {
            // Instantiate the Storage Account
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", Settings.Default.StorageAccountName, Settings.Default.StorageAccessKey));

            string cdnUrl = !string.IsNullOrWhiteSpace(Settings.Default.StorageCDNUrlOverride) ? Settings.Default.StorageCDNUrlOverride : storageAccount.BlobEndpoint.AbsoluteUri;
            if (!cdnUrl.EndsWith("/"))
            {
                cdnUrl += "/";
            }

            // Create the blob client.
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            // Process pending images
            AzureMediaManager.ManageAzurePhotos(blobClient, Settings.Default.StorageMediaContainerName, cdnUrl);

        }
    }
}
